|
|
|
|
|
|
|
Creating User-Drawn Controls |
|
|
|
|
|
|
|
|
The two preceding approaches have the advantage of being incredible easy to use. User-drawn controls represent one of the most exciting approaches that you can use for control creation, although the difficulty jumps astronomically. With this type of control, you work primarily with properties and events of the UserControl object. User-drawn controls are used whenever your new control had nothing in common with any existing controls. You would actually define all the control's properties, methods, and events while drawing the control so that it looks exactly the way you want it to. |
|
|
|
|
|
|
|
|
The ActiveX control that you create, with any of these three methods, will look and act like any other controls. You can insert them into the toolbox windows, double-click the control to add it to the form, and select its properties form the Properties window. Also, the control can support property pages, such as the one that appears when you click the Font property's ellipsis. |
|
|
|
|
|
|
|
|
Creating a Small Custom Control |
|
|
|
|
|
|
|
|
So that you can get an understanding of what it takes to create an ActiveX control, you'll create a small, fairly simple custom control with the properties, methods, events, and controls listed in Table 11.1. |
|
|
|
|
| TABLE 11.1. SIMPLE ACTIVEX CONTROL ELEMENTS. | | Name | Description | | | | TableName | Contains the table name or a SQL statement | | DisplayField | Contains the number of columns displayed | | | | Refresh | Refreshes the database control when executed | | | | Click | Triggered when users click the control's Continue button | | | | Data | Accesses the table in the specified database | | ComboBox | Displays the data from the specified field in the table | | CommandButton | Returns control to the calling form |
|
|
|